package com.github.xaidanwang.handler;


import com.github.xaidanwang.exception.auth.TokenException;
import com.github.xaidanwang.exception.valid.ParamException;
import com.github.xaidanwang.response.CommonResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author wang yi fei
 * @date 2019/9/24 9:57
 */
@RestControllerAdvice(value = "com.github.xaidanwang")
public abstract class BaseExceptionHandler {
	@ExceptionHandler(value = TokenException.class)
	public CommonResult dealTokenException(TokenException e){
		return CommonResult.buildWithData(false,e.getErrCode(),e.getMessage(),null);
	}

	@ExceptionHandler(value = ParamException.class)
	public CommonResult dealTokenException(ParamException e){
		return CommonResult.buildWithData(false,e.getErrCode(),e.getMessage(),null);
	}
}
